package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.FileUploadService;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * ClassName: FileUploadController
 * Package:
 * Description:
 *
 * @Author:xiaohei
 * @Create 2024/5/18 21:05
 * Version 1.0
 */
@RestController
@RequestMapping("/admin/system")
public class FileUploadController {

    @Resource
    private FileUploadService fileUploadService;

    //<input type="file" name="file"/>
    @PostMapping("/fileUpload")
    public Result fileUpload(MultipartFile file){
        //1 获取上传到的文件

        //2 调用service中方法实现文件上传
        String url = fileUploadService.upload(file);
        return Result.build(url, ResultCodeEnum.SUCCESS);
    }

}
